<?php
/*
 * 匹配关键词
 * 检查表
 *      xd_xxx,
 *      xd_xxx_data
 *      xx/201307/31/
 *      xxx/SpiderResult.db3
 * @package    system
 * @author     Mark
 * @copyright  Copyright (c) 2013 ixdcw team
 * @version    $Id: ea3003e4334e528b90f1d107ff3d390021b01378 $
 */
set_time_limit(0);
include '../../common.inc.php';
error_reporting(E_ALL);
$pdo = new PDO('mysql:host=192.168.1.19;dbname=ixdcw', 'root', 'root');
$pdo->query('set names utf8');
$sql = "select * from xd_auto_category where arid>$startid and level=1 and typename='rank' limit 1";
$ds = $pdo->query($sql);
$all = $ds->fetchAll();

if (!$all) {
	exit('over');
} else {
	foreach ($all as $k => $v) {
		$all = AutoManufactor::cars($v['arid']);
		var_dump($all);
		$arids = (array) __($all)->pluck('arid');
		$sql = "update xd_auto_category set keyword += ',{$v['name']}' where arid in(".implode(',', $arids).")";
		$pdo->query($sql);
		$startid = $v['arid'];
	}
}
echo '<meta http-equiv="refresh" content="1; url=' . Env::nquri() . '?startid=' . $startid . '" />';